package demo;

import demo.component.UserComponent;
import demo.config.UserConfig;
import demo.config.UserInfo;
import demo.controller.UserController;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
public class IOcApplication {

    public static void main(String[] args) {

        ApplicationContext context = SpringApplication.run(IOcApplication.class, args);

        UserController bean1 = (UserController) context.getBean("userController");
        bean1.sayHi();

        UserInfo bean2 = context.getBean("u1",UserInfo.class);
        System.out.println(bean2);

        UserInfo bean3 = context.getBean("u2",UserInfo.class);
        System.out.println(bean3);

        UserComponent bean = context.getBean(UserComponent.class);
        bean.doComponent();
    }

}
